#include "TcpServer.hpp" // 网络通信开断连接 //会话层
#include <memory>
#include "Protocol.hpp"
#include "Parser.hpp"
#include "Calculator.hpp"
void Usag(string buffer)
{
    cout<<buffer<< "+ port";
}
Response cb(Request& request )
{
    Response resp;
    // TODO: 根据request计算结果并设置resp
    return resp;
}
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        string buffer = argv[0];
        Usag(argv[0]);
        exit(0);
    }
    EnableConsoleLogStrategy();
    uint16_t serverport = std::stoi(argv[1]);
     std::unique_ptr<Calculator> cal = std::make_unique<Calculator>();

    // 协议解析的模块
    std::unique_ptr<Parser> parser = std::make_unique<Parser>([&cal](Request &req)->Response{
        return cal->Exec(req);
    });
    std::unique_ptr<TcpServer> tsock = std::make_unique<TcpServer>(
        serverport, [&parser](std::string &inbuffer)->std::string{
            return parser->Parse(inbuffer);
    });
    tsock->run();
}